﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>drag</title>
   
    <link href="static/drag-master/resize/resize.css" rel="stylesheet" />
    <style>
          .apps {
            position: absolute;
            height: 800px;
            width:1000px;
           
            cursor: move;
        }
        .box {
            position: absolute;
            height: 50px;
            margin-bottom: 30px;
            cursor: move;
        }

        .ddd {
            position: absolute;
            height: 50px;
            margin-bottom: 30px;
            cursor: move;
        }

        .box1 {
            top: 10px;
            width: 50px;
            background-color: red;
        }

        .box2 {
            top: 100px;
            width: 80px;
            background-color: green;
        }

        .box3 {
            top: 160px;
            width: 60px;
            background-color: yellow;
        }

        .box4 {
            top: 260px;
            width: 100px;
            background-color: gray;
        }
    </style>
</head>
<body>
    <div id="apps" class="apps" style="width:1000px;height:800px;">



        <div class="box box1">
            <div class="resize-box">
                <div class="resize resize-line line-xt">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-xb">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yl">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yr">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-dot dot-lt"></div>
                <div class="resize resize-dot dot-rt"></div>
                <div class="resize resize-dot dot-lb"></div>
                <div class="resize resize-dot dot-rb"></div>
            </div>
        </div>
        <div class="box box2">
            <div class="resize-box">
                <div class="resize resize-line line-xt">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-xb">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yl">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yr">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-dot dot-lt"></div>
                <div class="resize resize-dot dot-rt"></div>
                <div class="resize resize-dot dot-lb"></div>
                <div class="resize resize-dot dot-rb"></div>
            </div>
        </div>
        <div class="box box3">
            <div class="resize-box">
                <div class="resize resize-line line-xt">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-xb">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yl">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yr">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-dot dot-lt"></div>
                <div class="resize resize-dot dot-rt"></div>
                <div class="resize resize-dot dot-lb"></div>
                <div class="resize resize-dot dot-rb"></div>
            </div>
        </div>
        <div class="box box3">
            <div class="resize-box">
                <div class="resize resize-line line-xt">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-xb">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yl">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yr">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-dot dot-lt"></div>
                <div class="resize resize-dot dot-rt"></div>
                <div class="resize resize-dot dot-lb"></div>
                <div class="resize resize-dot dot-rb"></div>
            </div>
        </div>

        <div class="box box4">
            <div class="resize-box">
                <div class="resize resize-line line-xt">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-xb">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yl">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-line line-yr">
                    <div class="line-middle-dot"></div>
                </div>
                <div class="resize resize-dot dot-lt"></div>
                <div class="resize resize-dot dot-rt"></div>
                <div class="resize resize-dot dot-lb"></div>
                <div class="resize resize-dot dot-rb"></div>
            </div>
        </div>
    </div> 
    <script src="static/jquery/jquery-2.1.4.min.js"></script>
    
    <script src="static/drag-master/drag/drag.js"></script>
    <script src="static/drag-master/resize/resize.js"></script>
    <script src="static/drag-master/ref-line.js"></script>
     
    <script>
        Array.prototype.contains = function (val) {
            for (var i = 0; i < this.length; i++) {
                if (this[i] == val) {
                    return true;
                }
            }
            return false;
        };
        // demo url https://think2011.net/ref-line/
        const refLine = new RefLine(),
              resize = new Resize({
                  resizeParentSelector: '.box'
              }),
              boxes = document.querySelectorAll('.box');

        new Drag({
            selector: '.box',
            downCallBack (currElem) {
                // currElem.siblings
                currElem.classList.add('curr-move')
            },
            moveCallBack (currElem) {
                refLine.check(currElem, boxes)
            },
            upCallBack () {
                refLine.uncheck()
            }

        });
        new Drag({
            selector: '.box',
            downCallBack (currElem) {
                // currElem.siblings
                currElem.classList.add('curr-move')
            },
            moveCallBack (currElem) {
                refLine.check(currElem, boxes)
            },
            upCallBack () {
                refLine.uncheck()
            }

        });
        new Drag({
            selector: '.box',
            downCallBack (currElem) {
                // currElem.siblings
                currElem.classList.add('curr-move')
            },
            moveCallBack (currElem) {
                refLine.check(currElem, boxes)
            },
            upCallBack () {
                refLine.uncheck()
            }

        });


    </script>
</body>
</html>